package com.solcoo.customer.ui.card;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.solcoo.customer.ApplicationExt;
import com.solcoo.customer.Constant;
import com.solcoo.customer.R;
import com.solcoo.customer.base.task.TaskHelper;
import com.solcoo.customer.base.task.TaskHelper.Callback;
import com.solcoo.customer.base.task.TaskHelper.DefaultCallback;
import com.solcoo.customer.model.CardListDO;
import com.solcoo.customer.ui.ToolBarActivity;
import com.solcoo.customer.ui.shop.ShopDetailActivity;

public class CardActivity extends ToolBarActivity {

	// http://42.120.7.37/Solcoo/shRecharge.do?shanghuid=05382&shoujih=13700000001&jine=100
	// 充值链接

	CardAdapter adapter;

	ListView cardList;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.card);
		cardList = (ListView) findViewById(R.id.card_list);
		adapter = new CardAdapter(this);
		cardList.setAdapter(adapter);
		cardList.setOnItemClickListener(ShopDetailActivity.shopOnItemClickListener);
		TaskHelper.loadView(this, Constant.URL.getCardList(
				ApplicationExt.getUser().yonghum, adapter.cursor), callback,
				CardListDO.class);
	}

	private Callback<CardListDO> callback = new DefaultCallback<CardListDO>(
			this) {

		@Override
		public void onSuccess(CardListDO result) {
			adapter.update(result);
		}
	};

	@Override
	protected int getCurId() {
		return R.id.card_btn;
	}

	@Override
	public View showNotData() {
		View v = super.showNotData();
		TextView wordView = (TextView) v.findViewById(R.id.no_data_desc);
		wordView.setText("您尚无会员卡");
		return v;
	}
}
